Method: rich.pretty.traverse.<locals>.to_repr
Calls: 326, Exceptions: 1, Paths: 4Back
Path 1: 319 calls (0.98)
1 (74) 2 (27) 'foo' (26) 0 (15) None (14) 'Hello World' (11) 'bar' (10) 3 (9) False (7) True (7)
'1' (74) '2' (27) "'foo'" (26) '0' (15) 'None' (14) "'Hello World'" (11) "'bar'" (10) '3' (9) 'False' (7) 'True' (7)
1def to_repr(obj: Any) -> str:
2 """Get repr string for an object, but catch errors."""
3 if (
4 max_string is not None
5 and _safe_isinstance(obj, (bytes, str))
6 and len(obj) > max_string
7 ):
8 truncated = len(obj) - max_string
9 obj_repr = f"{obj[:max_string]!r}+{truncated}"
10 else:
11 try:
12 obj_repr = repr(obj)
13 except Exception as error:
14 obj_repr = f"<repr-error {str(error)!r}>"
15 return obj_repr
Path 2: 5 calls (0.02)
1 (2) test_inspect_swig_edge_case.
'1' (2) '
1def to_repr(obj: Any) -> str:
2 """Get repr string for an object, but catch errors."""
3 if (
4 max_string is not None
5 and _safe_isinstance(obj, (bytes, str))
6 and len(obj) > max_string
7 ):
8 truncated = len(obj) - max_string
9 obj_repr = f"{obj[:max_string]!r}+{truncated}"
10 else:
11 try:
12 obj_repr = repr(obj)
13 except Exception as error:
14 obj_repr = f"<repr-error {str(error)!r}>"
15 return obj_repr
Path 3: 1 calls (0.0)
test_broken_repr.
"
ZeroDivisionError (1)
1def to_repr(obj: Any) -> str:
2 """Get repr string for an object, but catch errors."""
3 if (
4 max_string is not None
5 and _safe_isinstance(obj, (bytes, str))
6 and len(obj) > max_string
7 ):
8 truncated = len(obj) - max_string
9 obj_repr = f"{obj[:max_string]!r}+{truncated}"
10 else:
11 try:
12 obj_repr = repr(obj)
13 except Exception as error:
14 obj_repr = f"<repr-error {str(error)!r}>"
15 return obj_repr
Path 4: 1 calls (0.0)
'HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello' (1)
"'HelloHel'+92" (1)
1def to_repr(obj: Any) -> str:
2 """Get repr string for an object, but catch errors."""
3 if (
4 max_string is not None
5 and _safe_isinstance(obj, (bytes, str))
6 and len(obj) > max_string
7 ):
8 truncated = len(obj) - max_string
9 obj_repr = f"{obj[:max_string]!r}+{truncated}"
10 else:
11 try:
12 obj_repr = repr(obj)
13 except Exception as error:
14 obj_repr = f"<repr-error {str(error)!r}>"
15 return obj_repr